package com.example.lib_core.http;

import android.util.Log;
import android.widget.Toast;

import com.example.lib_core.init.Core;

import io.reactivex.observers.DisposableCompletableObserver;
import io.reactivex.observers.DisposableObserver;

//DisposableObserver提供订阅关系的操作 ----》是否有订阅，取消订阅销毁线程
//isDisposed  是否被订阅
//dispose 取消订阅
public abstract class BaseObserver<T> extends DisposableObserver<T> implements IObserver<T>{

    @Override
    public void onNext(T t) {
        success(t);
    }

    @Override
    public void onError(Throwable e) {
        defeat(e.getMessage());
    }

    @Override
    public void onComplete() {

    }

    @Override
    public void defeat(String msg) {
        Toast.makeText(Core.getInstance().getApplication(), ""+msg, Toast.LENGTH_SHORT).show();
        Log.i("TAG", "defeat:----------> "+msg);
    }
}
